﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ScriptDumper.Manager
{
    public class DbTable
    {
        public string TableName
        { get; set; }

        public string UsedModule { get; set; }

        public string ShortTableName
        {
            get
            {
                if (!string.IsNullOrEmpty(TableName))
                {
                    return TableName.Replace("TB_", "").Replace("TV_", "");
                }

                return TableName;
            }
        }

        public string Description { get; set; }

        public string EnglishDescription { get; set; }

        public bool ContainsLog { get; set; }

        public bool ContainsHistory { get; set; }

        public bool Exportable { get; set; }

        private DbColumn[] _columns;
        public DbColumn[] Columns
        {
            get
            {
                _columns = new DbColumn[DbColumns.Keys.Count];
                DbColumns.Values.CopyTo(_columns, 0);
                return _columns;
            }
            set
            {
                _columns = value;
            }
        }

        private Dictionary<string, DbColumn> _dbColumns;
        public Dictionary<string, DbColumn> DbColumns
        {
            get
            {
                if (_dbColumns == null)
                    _dbColumns = new Dictionary<string, DbColumn>();
                return _dbColumns;
            }
            set
            {
                _dbColumns = value;
            }
        }

        private string _tablespace = "MASTER_DATA_TBL";
        public string Tablespace
        {
            get
            {
                return _tablespace;
            }
            set
            {
                _tablespace = value;
            }
        }

        private string _indexTablespace = "MASTER_DATA_IDX";
        public string IndexTablespace
        {
            get
            {
                return _indexTablespace;
            }
            set
            {
                _indexTablespace = value;
            }
        }
    }
}
